<?php
//xml_check.php



    function description_xml_check($t_array, $action='', $contrib='') {
        if($t_array[0]) {
            for($loop_index = 0; $loop_index<count($t_array); $loop_index++) {
                    if($t_array[$loop_index]['DETAILS']) {
                        if(!isset($t_array[$loop_index]['DETAILS'][0]['@']['CONTRIB_REF']))     return NO_CONTRIB_REF_PARAMETER_IN_DETAILS_TAG_TEXT;
                        if(!isset($t_array[$loop_index]['DETAILS'][0]['@']['FORUM_REF']))     return NO_FORUM_REF_PARAMETER_IN_DETAILS_TAG_TEXT;
                        if(!isset($t_array[$loop_index]['DETAILS'][0]['@']['CONTRIB_TYPE']))     return NO_CONTRIB_TYPE_PARAMETER_IN_DETAILS_TAG_TEXT;
                        if(!isset($t_array[$loop_index]['DETAILS'][0]['@']['STATUS']))     return NO_STATUS_PARAMETER_IN_DETAILS_TAG_TEXT;
                        if(!isset($t_array[$loop_index]['DETAILS'][0]['@']['LAST_UPDATE']))     return NO_LAST_UPDATE_PARAMETER_IN_DETAILS_TAG_TEXT;
                    } else     return NO_DETAILS_TAG_IN_DESCRIPTION_SECTION_TEXT;
                    if(!$t_array[$loop_index]['COMMENTS'][0]['#'])     return NO_COMMENTS_TAG_IN_DESCRIPTION_SECTION_TEXT;
                    if(!$t_array[$loop_index]['CREDITS'][0]['#'])     return NO_CREDITS_TAG_IN_DESCRIPTION_SECTION_TEXT;
            }
        }
    }





    function php_xml_check($t_array, $action='', $contrib='') {
        if($t_array[0]) {
            for($loop_index = 0; $loop_index<count($t_array); $loop_index++) {
                if ($action=='install') {
                    if(!$t_array[$loop_index]['INSTALL'][0]['#'])   $config_file_errors.=NO_INSTALL_TAG_IN_PHP_SECTION_TEXT . ($loop_index + 1)."<br>";
                } elseif ($action=='remove') {
                    if(!$t_array[$loop_index]['REMOVE'][0]['#']) {
                        $config_file_errors.="<div class=\"section\"><font class=\"section-title\">".NO_REMOVE_TAG_IN_PHP_SECTION_TEXT.
                                                 "</font><p class=\"code\">" . htmlentities($t_array[$loop_index]['INSTALL'][0]['#']) . "</p></div>";
                    }
                }
            }
        }
        return $config_file_errors;
    }


    function sql_xml_check($t_array, $action='', $contrib='') {
        if($t_array[0]) {
            for($loop_index = 0; $loop_index<count($t_array); $loop_index++) {
                if(!$t_array[$loop_index]['QUERY'][0]['#'])   $config_file_errors.=NO_QUERY_TAG_IN_SQL_SECTION_TEXT . ($loop_index + 1)."<br>";
                if(!$t_array[$loop_index]['REMOVE_QUERY'][0]['#']) {
                    $config_file_errors.="<div class=\"section\"><font class=\"section-title\">".NO_REMOVE_QUERY_NESSESARY_FOR_SQL_QUERY_TEXT.
                                                "</font><p class=\"code\">" . htmlentities($t_array[$loop_index]['QUERY'][0]['#']) . "</p></div>";
                }
            }
        }
        return $config_file_errors;
    }


    function make_dir_xml_check($t_array, $action='', $contrib='') {
        if($t_array[0]) {
            for($loop_index = 0; $loop_index<count($t_array); $loop_index++) {
                if(!isset($t_array[$loop_index]['DIR'])) {
                    $config_file_errors.=NO_DIR_TAG_IN_MAKE_DIR_SECTION_TEXT . ($loop_index + 1)."<br>";
                }
                if(!isset($t_array[$loop_index]['DIR'][0]['@']['NAME'])) {
                    $config_file_errors.=NAME_OF_DIR_MISSING_IN_MAKE_DIR_SECTION_TEXT. ($loop_index + 1)."<br>";
                }
                if(!isset($t_array[$loop_index]['PARENT_DIR'][0]['@']['NAME'])) {
                    $config_file_errors.=NAME_OF_PARENT_DIR_MISSING_IN_MAKE_DIR_SECTION_TEXT. ($loop_index + 1)."<br>";
                }
            }
        }
        return $config_file_errors;
    }


    function findreplace_xml_check($t_array, $action='', $contrib='') {
        if($t_array[0]) {
            for($loop_index = 0; $loop_index<count($t_array); $loop_index++) {

                if(!$t_array[$loop_index]['FILE'][0]['@']['NAME'])    $error_msg="no file name; ";
                if(!$t_array[$loop_index]['FIND'][0]['#'])     $error_msg.="no find sections; ";
                if(!$t_array[$loop_index]['REPLACE'][0]['#'])     $error_msg.="no replace sections; ";
                if(( (!$t_array[$loop_index]['ORIGINALLINENUMBERS'][0]['@']['START'] || !$t_array[$loop_index]['ORIGINALLINENUMBERS'][0]['@']['END']) &&
                    $t_array[$loop_index]['ORIGINALLINENUMBERS'][0]['@']['TYPE'] != 'continued'))     $error_msg.="no linenumbers start, end or type.";

                if ($error_msg) {
                    return ERROR_IN_FINDREPLACE_SECTION_TEXT. ($loop_index + 1).": ".$error_msg."<br>".
                        (($t_array[$loop_index]['FILE'][0]['@']['NAME']) ? "file: ".$t_array[$loop_index]['FILE'][0]['@']['NAME'] :"")."<br>".
                        (($t_array[$loop_index]['FIND'][0]['#']) ? "find: ".nl2br(htmlentities($t_array[$loop_index]['FIND'][0]['#']))."<hr>" :"").
                        (($t_array[$loop_index]['REPLACE'][0]['#']) ? "replace: ".nl2br(htmlentities($t_array[$loop_index]['REPLACE'][0]['#']))."<br>" :"");
                }
                //echo $t_array[$loop_index]['FILE']['@']['NAME']."<br>";
            }
        }
    }


    function addcode_xml_check($t_array, $action='', $contrib='') {
        if ($t_array[0]) {
            for($loop_index = 0; $loop_index<count($t_array); $loop_index++) {
                if(!$t_array[$loop_index]['FILE'][0]['@']['NAME'])    $error_msg="no file name; ";
                if(!$t_array[$loop_index]['FIND'][0]['#'])     $error_msg.="no find sections; ";
                if(!$t_array[$loop_index]['ADD'][0]['#'])     $error_msg.="no add sections; ";
                if((!$t_array[$loop_index]['FINDLINENUMBERS'][0]['@']['START'] || !$t_array[$loop_index]['FINDLINENUMBERS'][0]['@']['END']) &&
                     $t_array[$loop_index]['FINDLINENUMBERS'][0]['@']['TYPE'] != 'continued' &&
                     $t_array[$loop_index]['FINDLINENUMBERS'][0]['@']['TYPE'] != 'new')     $error_msg.="no linenumbers start, end or type.";

                if ($error_msg) {
                    return ERROR_IN_ADDCODE_SECTION_TEXT. ($loop_index + 1).": ".$error_msg."<br>".
                        (($t_array[$loop_index]['FILE'][0]['@']['NAME']) ? "file: ".$t_array[$loop_index]['FILE'][0]['@']['NAME'] :"")."<br>".
                        (($t_array[$loop_index]['FIND'][0]['#']) ? "find: ".nl2br(htmlentities($t_array[$loop_index]['FIND'][0]['#'])) :"")."<br>";
                }
            }
        }
    }

    function del_file_xml_check($t_array, $action='', $contrib='') {
        if ($t_array[0]) {
            for($loop_index = 0; $loop_index<count($t_array); $loop_index++) {
                if(!$t_array[$loop_index]['FILE'])     $config_file_errors.=NO_FILE_TAG_IN_ADDFILE_SECTION_TEXT.($loop_index + 1)."<br>";
                if(!$t_array[$loop_index]['FILE'][0]['@']['NAME']) {
                    $config_file_errors.=NAME_OF_FILE_MISSING_IN_DEL_FILE_SECTION_TEXT. ($loop_index + 1)."<br>";
                }
            }
        }
    }

    function addfile_xml_check($t_array, $action='', $contrib='') {
        if ($t_array[0]) {
            for($loop_index = 0; $loop_index<count($t_array); $loop_index++) {
                if(!$t_array[$loop_index]['FILE'])     $config_file_errors.=NO_FILE_TAG_IN_ADDFILE_SECTION_TEXT.($loop_index + 1)."<br>";
                if(!$t_array[$loop_index]['FILE'][0]['@']['NAME']) {
                    $config_file_errors.=NAME_OF_FILE_MISSING_IN_ADDFILE_SECTION_TEXT. ($loop_index + 1)."<br>";
                }
            }
        }
    }

?>